<template>
	<ls-page :hidden="true" :hideTopbar="true" backgroundImage="https://jtmc.oss-cn-hangzhou.aliyuncs.com/wmp/ch/common/i_back.png" :default-bg="false">
		<view class="promoteCode-container">
			<view class="promoteCode-container-h2">
				{{shopInfo.orgName ? shopInfo.orgName: ''}}
			</view>
			<view class="promoteCode-container-main" v-if="activeInfo.ScanCodePic">
				<image :src="activeInfo.ScanCodePic" class="main-center" mode=""></image>
				<view class="main-title">
					{{activeInfo.ScanCodeName}}
				</view>
				<view class="main-btn" @click="goToCou">
					开心收下
				</view>
				<view class="main-sub">
					{{activeInfo.ScanCodeSubTitle}}
				</view>
			</view>
			<!-- <image class="promoteCode-img" src="https://oss.jtmckj.com/wmp/images/account/i_cover.png" mode="aspectFill" />   -->
		</view>
	</ls-page>
</template>

<script setup>
	import { ref } from 'vue';
	import { onLoad, onShow } from '@dcloudio/uni-app';
	import { HFiveMemberAppObjProcess } from '@/api/public.js'
	const shopInfo = uni.getStorageSync('shopInfo')
	const goToCou = ()=>{
		uni.showLoading({
		    title: '领取中，请稍等',
		    mask: true, // 显示遮罩层
		    maskClickable: false // 遮罩层不可点击
		});
		HFiveMemberAppObjProcess({ functionName: "ScanCodeActiveCollection_H5", contentData: {activeCode:scanInfo.value?.active} })
		.then((res) => {
			console.log(res);
			uni.hideLoading()
			uni.showToast({ title: '领取成功', icon: 'none' })
			uni.reLaunch({
			  url: '/pages/coupon/index'
			})
		})
		.catch(err =>{
			
		})
	
	}
	let scanInfo = ref('')
	const activeInfo = ref('')
	onLoad((options) => {
		scanInfo.value = uni.getStorageSync('scanInfo')
		if(!scanInfo.value.active){
			uni.showToast({ title: '没有活动编码，请确认二维码是否正确', icon: 'none' })
			return
		}
		HFiveMemberAppObjProcess({ functionName: "GetScanCodeActiveInfo_H5", contentData: {activeCode:scanInfo.value?.active} })
		.then((res) => {
			activeInfo.value = res
		})
		.catch(err =>{
			
		})
	}); 
	
	
	
	
	
</script>

<style lang="less" scoped>
	::v-deep .u-navbar--fixed{
		display: none;
	}
	.promoteCode-container {
		overflow: scroll;
		width: 100%;
		height: 100%;
		box-sizing: border-box;
		padding: 36rpx 0rpx 0;
		background-color: var(--one--back-color);
		// background-image:url('https://oss.jtmckj.com/wmp/images/account/i_back_top.png');
		background-repeat: no-repeat;
		background-size: 100% 540rpx;
		background-position: center top;
		padding-bottom: 40rpx;
		position: relative;

		.promoteCode-container-h2 {
			font-family: PingFang SC;
			font-weight: bold;
			font-size: 28rpx;
			color: #FFFFFF;
			line-height: 28rpx;
			padding: 0 0 132rpx 32rpx;
		}

		.promoteCode-container-main {
			// background-image:url('https://oss.jtmckj.com/wmp/images/account/i_cover.png');
			background-repeat: no-repeat;
			background-size: 100% 432rpx;
			background-position: center bottom;
			display: flex;
			flex-direction: column;
			// justify-content: space-between;
			// align-items: center;
			.main-center {
				
				margin: 0 auto;
				height: 984rpx;
				// background-image: url('https://jtmc.oss-cn-hangzhou.aliyuncs.com/wmp/ch/common/i_gift.png');
				background-repeat: no-repeat;
				background-size: 640rpx 984rpx;
				background-position: center top;
			}
			.main-title{
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 28rpx;
				color: #F62159;
				line-height: 28rpx;
				text-align: center;
				padding: 47rpx 0 20rpx 0;
			}
			.main-btn{
				width: 320rpx;
				height: 80rpx;
				background: #F62159;
				border-radius: 40rpx;
				font-family: PingFang SC;
				font-weight: bold;
				font-size: 32rpx;
				color: #FFFFFF;
				line-height: 80rpx;
				text-align: center;
				margin: 0 auto;
			}
			.main-sub{
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 28rpx;
				color: #CCCCCC;
				line-height: 28rpx;
				text-align: center;
				padding: 40rpx 0 59rpx 0;
			}

		}
	}
</style>